﻿@{
    ViewBag.Title = "ProductList";
}

<div id="cphMain_ctl00_ContentPane" class="center">
    <div id="Breadcrumb" class="Breadcrumb">
        <ul>
            <li class="first">
                <a href='javascript:;' onclick="javascript:loadAction('Index2','Main')">Trang chủ
                </a>
            </li>
            <li>
                <a href='javascript:;' onclick="javascript:loadAction('personal','Account')">Tài khoản của tôi</a>
            </li>
            <li>
                <span>Danh sách sản phẩm</span>
            </li>
        </ul>
    </div>

<div class="Account-Module DefaultModule">
    
<div class="Block DefaultModule">
    

    <div id="CartHeader" class="Block Moveable Panel">
        <h2>
            Danh sách sản phẩm
        </h2>
    </div>

    <div id="CartContainer" class="Block Moveable Panel">

        <div class="BlockContent">
            @if (ViewBag.proList != null)
            {
                @*<form action="cartHandler" method="post">*@
                    <div class="Clear">
                        <div class="FloatRight">
                            <a href="javascript:;" onclick="javascript:loadAction('ProductDetail','Admin')" 
                                class="myBtn1">Thêm sản phẩm mới</a>
                        </div>
                    </div>

                    <div class="Clear">
                    </div>

                    <div>
                        <div>

                            <table class="CartContents" cellspacing="0" rules="rows" border="1" id="cphMain_ctl00_ctl01_ctl00_grvList" style="width: 100%; border-collapse: collapse;">
                                <tbody>
                                    <tr class="even-row">
                                        <th align="left" scope="col">Sản phẩm
                                        </th>
                                        <th>
                                            Hình ảnh
                                        </th>
                                        <th scope="col">Khuyến mãi
                                        </th>
                                        <th align="right" scope="col">Giá
                                        </th>
                                        <th align="center" scope="col">Trạng thái
                                        </th>
                                        <th scope="col">&nbsp;</th>
                                    </tr>
                                    @{var rowCount = 0; string cssRowClass = "";}
                                    @foreach (var pro in ViewBag.proList)
                                    {
                                        if (++rowCount % 2 == 1) { cssRowClass = "old-row"; }
                                        else { cssRowClass = "even-row"; }
                                        <tr class="@cssRowClass">
                                            <td align="left">
                                                <a href="javascript:;" onclick="javascript:viewProductDetail(@pro.ID)">
                                                    <strong>@pro.name</strong></a>
                                                <div style="font-style: italic;"></div>
                                                <br>                                                                                                
                                            </td>
                                            <td align="center">
                                                <a href="javascript:;" onclick="javascript:viewProductDetail(@pro.ID)">
                                                    <img src="/Content/data/images/350.300/@pro.image_link" height="80"/>
                                                </a>
                                            </td>
                                            <td align="center" style="width: 70px;">
                                                @if(pro.promotion_ID > 0 )
                                                {
                                                <span>@pro.Promotion.title</span>
                                                }else
                                                {
                                                    <span></span>
                                                }
                                            </td>
                                            <td align="right" style="width: 80px;">                                                
                                                @{var price = Convert.ToInt32(pro.price);
                                                 }
                                                @if(pro.promotion_ID > 0)
                                                {
                                                 <strike>@Convert.ToInt32(pro.price) VND / thùng</strike>
                                                <br/>
                                                    price = Convert.ToInt32(pro.price / 100 * (100 - pro.Promotion.rate));
                                                <span>@price VND / thùng</span>                                                 
                                                }
                                                else
                                                {
                                                <span>@price VND / thùng</span>
                                                }
                                            </td>
                                            <td align="center" style="width: 90px;">                                                
                                               @if (pro.is_selling)
                                               {
                                                   <span>Có</span>
                                               }else
                                               {
                                                   <span>Không</span>
                                               }
                                            </td>
                                            <td align="center" style="width: 1px;">
                                                <a href="javascript:;" onclick="javascrip:deleteProduct(@pro.ID)" class="myBtn1">Xóa</a>
                                            </td>
                                        </tr>
                                    }
                                </tbody>
                            </table>

                        </div>

                    </div>

                            <div class="PageNavigation" style="padding-bottom: 10px; padding-top: 10px;" align="center">
            @{var previousPage = Math.Max(ViewBag.currentPage-1, 1);}
            <a  href="javascript:;" onclick="javascript:loadActionData('ProductList','Admin','pageNum=@previousPage')">&lt;&lt;</a>    
            @for(int num = 1; num <= ViewBag.maxPage; num ++)
            {
               if(ViewBag.currentPage == num)
               {
                  <a class="active" href="#" 
                      style="background-color:gray;color:white;"><strong>@num</strong></a>
                }
                else
                {
                   <a  href="javascript:;" onclick="javascript:loadActionData('ProductList','Admin','pageNum=@num')">@num</a>    
                }
            }                   
            @{var nextPage = Math.Min(ViewBag.maxPage, ViewBag.currentPage + 1);}
            <a href="javascript:;" onclick="javascript:loadActionData('ProductList','Admin','pageNum=@nextPage')">&gt;&gt;</a>    
        </div>

                @*</form>*@
            }
            
        </div>
    </div>        
</div>


</div>
</div>

